package main

import (
	"database/sql"
	"fmt"
	_ "github.com/go-sql-driver/mysql"
)

var (
	id       int
	username string
)

func main() {

	db, err := sql.Open("mysql", "root:mysqltest@tcp(fsdev.me:3306)/jujubao")
	if err != nil {
		panic(err.Error()) // Just for example purpose. You should use proper error handling instead of panic
	}
	defer db.Close()
	rows, err := db.Query("select id ,username from ju_user")
	if err != nil {
		fmt.Println(nil)
	}

	defer rows.Close()
	fmt.Println(rows.Columns())
	for rows.Next() {

		err := rows.Scan(&id, &username)

		if err != nil {
			fmt.Println(err)
			continue
		}
		fmt.Println(id, username)
	}
	err = rows.Err()
	if err != nil {
		fmt.Println(err)
	}
}
